package mest.service.Modeling.Impl;

import mest.dao.Modeling.IcarFileDao;
import mest.entity.car_file;
import mest.entity.model_file;
import mest.service.Modeling.IcarFileService;
import mest.util.ResultObj;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description
 * @auther Machenike
 * @create 2019-11-15 23:11
 */
@Service
public class carFileServiceImpl implements IcarFileService {

    @Resource
    private IcarFileDao icfd;

    @Override
    public ResultObj insertCarFile(car_file ct,String theirDb) {
        try {
            int num = icfd.insertCarFile(ct, theirDb);
            if (num > 0) {
                return  ResultObj.createSuccessMsg(ResultObj.INSERT_SUCCESS);
            }
        } catch (Exception e) {
            e.printStackTrace();
            if (e.getClass().getName().equals("org.springframework.dao.DuplicateKeyException")) {
                return ResultObj.createErrorMsg("编码重复");
            }
        }
        return ResultObj.createErrorMsg(ResultObj.ERROR);
    }





    @Override
    public int selectCount(String theirDb) {
        return icfd.selectCount(theirDb);
    }

    @Override
    public List<car_file> findCarFilePage(int index, int pageSize,String theirDb) {
        return icfd.findCarFilePage((index-1)*pageSize,pageSize,theirDb);
    }


    @Override
    public int delModel(Integer id,String theirDb) {
        return icfd.delModel(id, theirDb);
    }

    @Override
    public List<car_file> queryAll(Integer index, Integer pageSize, String record,String theirDb) {
        return icfd.queryAll((index-1)*pageSize,pageSize,record,theirDb);
    }

    @Override
    public int findCount(String record,String theirDb) {
        return icfd.findCount(record,theirDb);
    }

    @Override
    public int updateByOne(car_file record,String theirDb) {
        return icfd.updateByPrimaryKeySelective(record,theirDb);
    }
}
